<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!--准备好一个容器-->
    <div id="test"></div>
    
    <!---引入react核心库-->
    <script type="text/javascript" src="./js/react.development.js"></script>
    <!--引入react-dom用于支持react操作dom-->
    <script type="text/javascript" src="./js/react-dom.development.js"></script>
    <!--引入babel用于将jsx转为js-->
    <script type="text/javascript" src="./js/babel.min.js"></script>
    <script type="text/javascript" src="./js/prop-types.js"></script>

    <script type="text/babel"> //此处一定要写
        
        class Demo extends React.Component{

            showData1=()=>{
                console.log("已点击")
                //const {input1}=this.refs
                const {input1} = this
                alert(input1.value)
            }
            showData2=()=>{
                console.log("已点击")
                // const {input2}=this.refs
                const {input2} = this
                alert(input2.value)
            }
            render(){
                return(
                    //这里的currentNode其实就是当前的input节点，把他赋值给this.input1,而这里的this，由于是箭头函数，this向外找，即render的this，render的this即Demo的this
                    <div>
                        <input ref={(currentNode)=>{this.input1=currentNode}} type="text" placeholder="点击按钮提示数据"/>&nbsp;
                        <button  onClick={this.showData1}>点我提示左侧数据</button>&nbsp;
                        <input ref={c=>this.input2=c}  onBlur={this.showData2} type="text" placeholder="点击焦点提示数据"/>
                        
                    </div>
                )

            }
        }
 
    ReactDOM.render(<Demo/>,document.getElementById("test"))
    </script>
</body>
</html>